import Vue from 'vue'
import Router from 'vue-router'
import Home from './pages/home'
import Index from './pages/index'



Vue.use(Router);

export default new Router({
  routes: [
    // 根路由 home
    {
      path: '/',
      name: 'home',
      component: Home,
      redirect: '/index',
      // 字路由 
      children: [
        // index 
        {
          path: '/index',
          name: 'index',
          component: Index,
        },
        // product
        {
          path: '/product/:id',
          name: 'product',
          component: () => import('./pages/product.vue')
        },
        // deatil
        {
          path: '/detail/:id',
          name: 'detail',
          component: () => import('./pages/detail.vue')
        }
      ]
    },
    // 根路由 login
    {
      path: '/login',
      name: 'login',
      component: () => import('./pages/login.vue')
    },
    // 根路由 cart
    {
      path: '/cart',
      name: 'cart',
      component: () => import('./pages/cart.vue'),
    },
    // 根路由 order
    {
      path: '/order',
      name: 'order',
      component: () => import('./pages/order.vue'),
      // 字路由
      children: [
        // order-- list
        {
          path: 'list',
          name: 'order-list',
          component: () => import('./pages/orderList.vue')
        },
        // order-- Confirm
        {
          path: 'confirm',
          name: 'order-confirm',
          component: () => import('./pages/orderConfirm.vue')
        },
        // order-- pay
        {
          path: 'pay',
          name: 'order-pay',
          component: () => import('./pages/orderPay.vue')
        },
        // order-- alipay
        {
          path: 'alipay',
          name: 'order-alipay',
          component: () => import('./pages/alipay.vue')
        }
      ]
    }
  ]
})